/**
 *  .vuepress/enhanceApp.js 增强
 *
 *  整合layer:  http://layer.zuoyanit.com/
 * @param Vue
 * @param options
 * @param router
 * @param siteData 
 */

import Element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import VueECharts from 'vue-echarts'
import layer from 'vue-layer'
import 'vue-layer/lib/vue-layer.css';

export default ({ Vue, options, router,siteData }) => {

    Vue.use(Element)
  	Vue.component('echart', VueECharts)

    Vue.prototype.$layer = layer(Vue);

    /**
     * 路由切换事件处理
     */
    router.beforeEach((to, from, next) => {
        //触发百度的pv统计
        if (typeof _hmt != "undefined") {
            let toPath = to.path;
            if (toPath && (toPath.indexOf('#')==-1) ) {
                _hmt.push(["_trackPageview", to.fullPath]);
                console.log("上报baidu统计", to.fullPath);
            }
        }
        //发送cnzz的pv统计
        if (typeof _czc != "undefined") {
            if (toPath && (toPath.indexOf('#')==-1) ) {
                _czc.push(["_trackPageview", to.fullPath, from.fullPath]);
                console.log("上报cnzz统计", to.fullPath);
            }
        }
        next(); // continue
    });

};